var util = require('../../utils/util.js')
const app = getApp()
let jinbiShareLgImg = ''
let jinbiShareText = ''
Page({
  inputValue: '',
  data: {
    indexImg:'',
    yuanshengAd1:'adunit-df84d2891075f223',
    moreJinb: false,
    isLiuliangTrue:false,
    videoSrc: null,
    posterSrc: null,
    imgSrc: null,
    appId:null
  },
  onShow: function () {

  },
  onLoad() {
    if(!app.globalData.isRegistered){
      app.selecteUser().then(res=>{
        app.globalData.isRegistered = res
      })
    }
    this.getController()//异步获取系统控制变量
    this.select_lookVideos_qiandao()
  },
  //异步获取系统控制变量
  getController() {
    if (app.globalData.SysController == null) {
      app.getController().then(res => {
        jinbiShareLgImg = res.jinbi_page_top_show.jinbiShareLgImg
        newsShareMinImg = res.jinbi_page_top_show.newsShareMinImg
        jinbiShareText = res.jinbi_page_top_show.jinbiShareText
       
        this.setData({
          moreJinb: res.controller_page.moreJinb,
          isLiuliangTrue : res.controller_page.isLiuliangTrue,
          yuanshengAd1:res.ad.yuansheng1,
          indexImg:res.indexImg
        })
      })
    } else {
      jinbiShareLgImg = app.globalData.SysController.jinbi_page_top_show.jinbiShareLgImg
      jinbiShareMinImg = app.globalData.SysController.jinbi_page_top_show.jinbiShareMinImg
      jinbiShareText = app.globalData.SysController.jinbi_page_top_show.jinbiShareText

      this.setData({
        moreJinb: app.globalData.SysController.controller_page.moreJinb,
        isLiuliangTrue : app.globalData.SysController.controller_page.isLiuliangTrue,
        yuanshengAd1:app.globalData.SysController.ad.yuansheng1,
        indexImg:app.globalData.SysController.indexImg
      })
    }
  },

  // 设置看视频数据表
  select_lookVideos_qiandao() {
    wx.cloud.callFunction({
      name: 'lookvideosqiandao',
      data: {
        yuanshengAd1: null,
        tag: 'select',
        _updateTime: util.formatTime(new Date()).slice(0, 10)
      }
    })
  },

  // 更多积分平台
  moreJinbi() {
    // console.log(app.globalData.gotoAppid.appid,'=============');
    wx.navigateToMiniProgram({
      appId: app.globalData.gotoAppid.appid,
      path: '/pages/news/news',
      envVersion: 'release',
      success(res) {
        // 打开成功
      }
    })
  },


 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: `${app.globalData.userInfo.nickName}带你${jinbiShareText}`,
      path: `/pages/news/news?shangjiOpenId=${app.globalData.userInfo._openid}`,
      imageUrl: jinbiShareLgImg,
    }
  },

})